
module.exports = function (app, port) {
  const options = {
    swaggerDefinition: {
      info: {
        description: 'API 文档',
        title: 'Swagger',
        version: '1.0.0'
      },
      host: `localhost:${port}`,
      basePath: '/',
      produces: ['application/json', 'application/xml'],
      schemes: ['http', 'https'],
      securityDefinitions: {
        JWT: {
          type: 'apiKey',
          in: 'header',
          name: 'Authorization',
          description: ''
        }
      }
    },
    route: {
      url: '/swagger',
      docs: '/swagger.json' // swagger文件 api
    },
    basedir: __dirname, // app absolute path
    files: ['../router/**/*.js'] // 扫描的文件,此处非常重要
  }

  const expressSwagger = require('express-swagger-generator')(app) // swagger api
  // https://localhost:8082/swagger
  expressSwagger(options)
}
